unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,fs_ipascal, fs_iformsrtti,fs_iinterpreter,fs_FHisCtrlRTTI,
  DB, DBClient, FHisDataSet, Grids, DBGrids, FEdit, FDicEdit, FText,
  FDBText, Mask, DBCtrls, FDBEdit, FDBDicEdit;

type
  TFormMain = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Memo1: TMemo;
    DataSetTmp: TFHisDataSet;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Button3: TButton;
    FDicEdit1: TFDicEdit;
    FText1: TFText;
    FDBText1: TFDBText;
    FDBDicEdit1: TFDBDicEdit;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
    fsScript1 : TfsScript;
  public
    { Public declarations }
  end;

var
  FormMain: TFormMain;

implementation
uses CusRptDesigner,PubData,PubDataAS,CusRepDesigner;

{$R *.dfm}

procedure TFormMain.Button1Click(Sender: TObject);
var
  vCusForm : TFormCusRptDesigner;
begin
  vCusForm := TFormCusRptDesigner.Create(Self);
  try
    vCusForm.WindowState := wsMaximized;
    vCusForm.ShowModal;

  finally
    vCusForm.Free;
  end;
end;

procedure TFormMain.FormCreate(Sender: TObject);
begin
  PubDataHisManager.CreatePubData(TPubDataHis, PubDataHis);
  PubDataHisManager.CreatePubData(TPubDataHisAS, TPubDataHis(PubDataHisAS));

  fsScript1 := TfsScript.Create(Self);

  DataSetTmp.DataServiceName := PubDataHisAS.DataServiceHis.DataServiceName;
  DataSetTmp.SQL.Text := 'select * from zd_ry';
end;

procedure TFormMain.FormDestroy(Sender: TObject);
begin
  PubDataHisManager.FreePubData(TPubDataHis(PubDataHisAS));
//  PubDataHisManager.FreePubData(PubDataHis);

  fsScript1.Free;
end;

procedure TFormMain.Button2Click(Sender: TObject);
begin
  fsScript1.Clear;
  fsScript1.Parent := fsGlobalUnit;
  fsScript1.AddComponent(FormMain);
  fsScript1.Lines.Assign(Memo1.Lines);
  if not fsScript1.Run then
    ShowMessage('script error: ' + fsScript1.ErrorMsg);

end;

procedure TFormMain.Button3Click(Sender: TObject);
begin
  fsScript1.Clear;
  fsScript1.Parent := fsGlobalUnit;
  fsScript1.AddComponent(FormMain);
  fsScript1.Lines.Clear;
  fsScript1.Lines.Add('begin FormMain.DataSetTmp.close; end.');
  if not fsScript1.Run then
    ShowMessage('script error: ' + fsScript1.ErrorMsg);
end;

procedure TFormMain.Button4Click(Sender: TObject);
var
  vCusForm : TFormCusRepDesigner;
begin
  vCusForm := TFormCusRepDesigner.Create(Self);
  try
    vCusForm.WindowState := wsMaximized;
    vCusForm.ShowModal;

  finally
    vCusForm.Free;
  end;

end;

end.
